<?php
namespace Admin\Model;
use Think\Model;

class ProjectsummaryLaborModel extends AbstractModel {

	protected $results = array();
	
	public $_validate = array(
        array('PSID','number','请选择项目总结ID',Model::MUST_VALIDATE,"function",1)
    );
	
	/*
	protected $_auto = array(
    	array('ProjectNO', 'getNowNO',3,'callback')
  	);
    */
	
	public function Myupadd(){
		if(!$this->create()){
			$this->results['msg'] = $this->getError();
			$this->results['state'] = 0;
		}else{
			$res = $this->add();
			if($res) {
				$this->results['state'] = 1;
				$this->results['msg'] = "添加成功！";
				$this->results['id'] = $res;
			}else{
				$this->results['state'] = 0;
				$this->results['msg'] = "添加错误！";
			}
		}
		return $this->results;
	}
	
	
	public function Myupdata(){
		if(!$this->create()){
			$this->results['msg'] = $this->getError();
			$this->results['state'] = 0;
		}else{
			$res = $this->save();
			if($res) {
				$this->results['state'] = 1;
				$this->results['msg'] = "修改成功！";
				$this->results['id'] = $res;
			}else{
				$this->results['state'] = 0;
				$this->results['msg'] = "修改错误！";
			}
		}
		return $this->results;
	}
	
	
	public function Myshow($parmArr){
		$fields = " a.*, b.UserName ";
		$join = " LEFT JOIN user AS b ON a.UserID = b.ID ";
		return $this->alias('a')->field($fields)->join($join)->WHERE($parmArr)->find();
	}
	
	public function MyshowList(){
		$where = "";
		$inid = "";
		$return = array();
		$count = $this->where($where)->count();
	    $page = $this->Mypage($count, 8);
	    $fields = " a.*, b.UserName ";
	    $join = " LEFT JOIN user AS b ON a.UserID = b.ID ";
		$res = $this->alias('a')->join($join)->where($where)->field($fields)->limit($page->firstRow.','.$page->listRows)->select();
		$return['list'] = $res;
		$return['page'] = $page->show('Admin');
		return $return;
	}
	
	
	public function getSummaryList(){
		$depat = M("projectsummary");
		//$where['IsDel'] = 0;
		return $depat->field('ID')->where()->select();
	}
	
}

?>				